package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.YonbipKmys;
import com.ruoyi.system.service.IYonbipKmysService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 科目映射Controller
 * 
 * @author ruoyi
 * @date 2025-09-15
 */
@Controller
@RequestMapping("/system/yonbipKmys")
public class YonbipKmysController extends BaseController
{
    private String prefix = "system/yonbipKmys";

    @Autowired
    private IYonbipKmysService yonbipKmysService;

    @RequiresPermissions("system:yonbipKmys:view")
    @GetMapping()
    public String yonbipKmys()
    {
        return prefix + "/yonbipKmys";
    }

    /**
     * 查询科目映射列表
     */
    @RequiresPermissions("system:yonbipKmys:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(YonbipKmys yonbipKmys)
    {
        startPage();
        List<YonbipKmys> list = yonbipKmysService.selectYonbipKmysList(yonbipKmys);
        return getDataTable(list);
    }

    /**
     * 导出科目映射列表
     */
    @RequiresPermissions("system:yonbipKmys:export")
    @Log(title = "科目映射", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(YonbipKmys yonbipKmys)
    {
        List<YonbipKmys> list = yonbipKmysService.selectYonbipKmysList(yonbipKmys);
        ExcelUtil<YonbipKmys> util = new ExcelUtil<YonbipKmys>(YonbipKmys.class);
        return util.exportExcel(list, "科目映射数据");
    }

    /**
     * 新增科目映射
     */
    @RequiresPermissions("system:yonbipKmys:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存科目映射
     */
    @RequiresPermissions("system:yonbipKmys:add")
    @Log(title = "科目映射", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(YonbipKmys yonbipKmys)
    {
        return toAjax(yonbipKmysService.insertYonbipKmys(yonbipKmys));
    }

    /**
     * 修改科目映射
     */
    @RequiresPermissions("system:yonbipKmys:edit")
    @GetMapping("/edit/{kmbm}")
    public String edit(@PathVariable("kmbm") String kmbm, ModelMap mmap)
    {
        YonbipKmys yonbipKmys = yonbipKmysService.selectYonbipKmysByKmbm(kmbm);
        mmap.put("yonbipKmys", yonbipKmys);
        return prefix + "/edit";
    }

    /**
     * 修改保存科目映射
     */
    @RequiresPermissions("system:yonbipKmys:edit")
    @Log(title = "科目映射", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(YonbipKmys yonbipKmys)
    {
        return toAjax(yonbipKmysService.updateYonbipKmys(yonbipKmys));
    }

    /**
     * 删除科目映射
     */
    @RequiresPermissions("system:yonbipKmys:remove")
    @Log(title = "科目映射", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(yonbipKmysService.deleteYonbipKmysByKmbms(ids));
    }
}
